package com.example.contact;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {
    String id = "2276198772";
    String pswd = "ljtyyds";
    EditText username = null;
    EditText password = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.login);
        username = (EditText) findViewById(R.id.username);
        password = (EditText) findViewById(R.id.password);
//        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
//            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
//            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
//            return insets;
//        });
        //这两句记得删除
//        Intent intent = new Intent(MainActivity.this, Contact.class);
//        startActivity(intent);
    }
    public void login(View view){
        if(username.getText().toString().trim().equals(id) && password.getText().toString().trim().equals(pswd)){
            Intent intent = new Intent(MainActivity.this, Contact.class);
            startActivity(intent);
        }
        else{
            Log.e("TAG", "login: " );
            Toast.makeText(MainActivity.this, "账号或者密码错误", Toast.LENGTH_SHORT).show();
        }
    }
}